﻿#pragma once

#include <DirectXMath.h>

namespace Base {

	using namespace DirectX;

	struct Vec2 {
		union
		{
			struct
			{
				float x;
				float y;
			};
			XMFLOAT2 data;
		};

		Vec2() {}
		Vec2(float px, float py) :x(px), y(py) {}

		Vec2& operator=(XMFLOAT2 v) {
			x = v.x;
			y = v.y;
			return *this;
		}

		Vec2 operator+(const Vec2& other)const {
			return Vec2(x + other.x, y + other.y);
		}

		/*Vec2& operator+=(const Vec2& other) {
			x += other.x;
			y += other.y;
			return *this;
		}*/


		Vec2 operator-(const Vec2& other)const {
			return Vec2(x - other.x, y - other.y);
		}
		Vec2 operator*(float scalar) const {
			return Vec2(x * scalar, y * scalar);
		}
		Vec2 operator/(float scalar) const;

		float Dot(const Vec2& other) const {
			return x * other.x + y * other.y;
		}


		//-------------------------------
		// static 方法
		static float Dot(const Vec2& lhs, const Vec2& rhs) {
			return lhs.Dot(rhs);
		}
	};
}


